package com.jxud.controller;

import com.jxud.pojo.Result;
import com.jxud.utils.AliOSSUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@Slf4j
public class uploadController {
    @Autowired
    private AliOSSUtils aliOSSUtils;

    @PostMapping("/upload")
    public Result uploadFile(MultipartFile file) throws Exception {
        log.info("文件上传文件名为：{}", file.getOriginalFilename());
        String url = aliOSSUtils.uploadFile(file);
        log.info("文件上传成功，文件名为：{}", url);
        return Result.success(url);
    }
}
